package com.yupi.yuojbackendjudgeservice.judge.codesandbox;


import com.yupi.yuojbackendmodel.model.codesandbox.ExcuteCodeRequest;
import com.yupi.yuojbackendmodel.model.codesandbox.ExcuteCodeResponse;
import lombok.extern.slf4j.Slf4j;

@Slf4j
//实现被代理的接口
public class CodeSandboxProxy implements CodeSandbox{

    private final CodeSandbox codeSandbox;
    //通过构造函数接受一个被代理的接口实现类
    public CodeSandboxProxy(CodeSandbox codeSandbox){
        this.codeSandbox = codeSandbox;
    }

    @Override
    //实现被代理的接口
    public ExcuteCodeResponse excuteCode(ExcuteCodeRequest excuteCodeRequest) {
        log.info("代码沙箱请求信息：" + excuteCodeRequest.toString());
        //调用被代理的接口实现类,在调用前后增加对应的操作
        ExcuteCodeResponse excuteCodeResponse = codeSandbox.excuteCode(excuteCodeRequest);
        log.info("代码沙箱响应信息：" + excuteCodeResponse.toString());
        return excuteCodeResponse;
    }
}
